home *** CD-ROM | disk | FTP | other *** search
- ******************************************************************
- * COPYRIGHT (C) 1986 by Donald Krantz and James Stanley
- * - Note: This is a real, live, actual, registered copyright,
- * and should be treated as such. This source code is from
- * the book "68000 Assembly Language", Krantz and Stanley,
- * Addison-Wesley Publishing Company, Reading, MA, 1986.
- *
- * Permission granted by the authors for non-commercial use
- * in programs released to the public domain, as long as this
- * copyright notice remains attached and visible.
- *
- *****************************************************************
- * Virtual Screen - Maintains a virtual interface to a slow
- * CRT output device. Scrolling not supported.
-
- lines equ 24 * lines on actual screen
- cols equ 80 * columns on actual screen
-
- xdef cls,cursor,putc,sync_curs,v_scrn
- xref _crt_cls,_crt_put,_crt_cursor
-
- * CLS
- * Clears the CRT. No parameters.
- *
- * CURSOR
- * Sets the cursor to an (X,Y) position. Calling sequence: push
- * Y, then X. X and Y are binary, zero-based, word length.
- *
- * PUTC
- * Outputs a character to the display. Calling sequence: push
- * the character to be output in the low byte os a word.
- *
- * SYNC_CURS
- * Syncs the actual CRT cursor the the virtual CRT cursor, as it
- * usually isn't where it ought to be, especially when doing
- * inputs. No parameters.
- *****************************************************************
- cls:
- movem.l a0/d0/d1,-(a7) * save user's registers
- move.w #(lines*cols),d0 Number of chars to blank
- lsr.w #1,d0 * Divide by to for word store
- move.w #' ',d1 * we'll use register for speed
- move.l #v_scrn,a0 * our memory copy
- bra loop_test * Go do loop test
- loop:
- move.w d1,(a0)+ * store two blanks at a crack
- loop_test:
- dbra d0,loop * loop thru all memory
- bsr _crt_cls * clear physical screen
- move.w #1,sync * set sync flag true
- move.l #v_scrn,my_curs * sync my cursor
- clr.l -(a7) * put two zero words on stack
- bsr _crt_cursor * sync user's cursor
- addq.l #4,a7 * adjust stack
- clr.w his_lin * clear user's line counter
- clr.w his_col * clear user's column counter
- movem.l (a7)+,a0/d0/d1 * restore user's registers
- rts
- *****************************************************************
- * Sets cursor to arbitrary screen location
- cursor:
- clr.w sync * set sync flag false
- move.w 4(a7),his_col * save crt screen X position
- move.w 6(a7),his_lin * save crt screen Y position
- move.l d0,-(a7) * save D0 across calculation
- clr.l d0 * start with clean register
- move.w 10(a7),d0 * get new line number
- mulu #cols,d0 * multiply by cols to get offset
- add.w 8(a7),d0 * add in column offset
- add.l #v_scrn,d0 * add base to get address
- move.l d0,my_curs * now we should be at same spot
- move.l (a7)+,d0 * restore d0
- rts
- *****************************************************************
- * Output character to screen if necessary
- putc:
- link a6,#0 * freeze stack frame
- movem.l d0/a0,-(a7) * save user's stuff
- move.w 8(a6),d0 * get char to output
- move.l my_curs,a0 * get my screen address
- cmp.b (a0),d0 * are they the same?
- beq no_put * jump if yes
- move.b d0,(a0) * Store char in virtual screen
- tst.w sync * are we synced?
- bne synced * jumps if synced
- bsr sync_curs * sync cursors
- synced:
- move.w 8(a6),-(a7) * push his character
- bsr _crt_put * send to crt
- addq.l #2,a7 * adjust stack
- bra did_put * set other vars
- no_put:
- clr.w sync * show out of sync
- did_put:
- addq.l #1,my_curs * increment my cursor
- addq.w #1,his_col * and his column count
- movem.l (a7)+,d0/a0 * restore user's stuff
- unlk a6
- rts
- *****************************************************************
- * SYNC_CURS - Syncs crt cursor to virtual cursor
- sync_curs:
- move.w d0,-(a7) * Saving char across put call
- move.w his_lin,-(a7) * Push Y address
- move.w his_col,-(a7) * Push X address
- bsr _crt_cursor * set actual cursor
- addq.l #4,a7 * adjust stack
- move.w #1,sync * show synced
- move.w (a7)+,d0 * restore character
- rts
- *****************************************************************
- bss
- sync: ds.w 1 * actual display synced flag
- v_scrn: ds.b (lines*cols) * virtual screen memory
- my_curs:ds.l 1 * virtual screen cursor location
- his_lin:ds.w 1 * actual screen line number
- his_col:ds.w 1 * actual screen column number
-
- end